<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>MySQL基本语句 | 番园</title>
  <meta name="keywords" content="">
  <meta name="description" content="MySQL基本语句 | 番园">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta property="og:type" content="website">
<meta property="og:title" content="番园">
<meta property="og:url" content="http://example.com/archives/index.html">
<meta property="og:site_name" content="番园">
<meta property="og:locale" content="en_US">
<meta property="article:author" content="ShuYePL">
<meta name="twitter:card" content="summary">


<link rel="icon" href="/img/avatar1.jpg">

<link href="/css/style.css?v=1.1.0" rel="stylesheet">

<link href="/css/hl_theme/atom-dark.css?v=1.1.0" rel="stylesheet">

<link href="//cdn.jsdelivr.net/npm/animate.css@4.1.0/animate.min.css" rel="stylesheet">

<script src="//cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script>
<script src="/js/titleTip.js?v=1.1.0" ></script>

<script src="//cdn.jsdelivr.net/npm/highlightjs@9.16.2/highlight.pack.min.js"></script>
<script>
    hljs.initHighlightingOnLoad();
</script>

<script src="//cdn.jsdelivr.net/npm/nprogress@0.2.0/nprogress.min.js"></script>



<script src="//cdn.jsdelivr.net/npm/jquery.cookie@1.4.1/jquery.cookie.min.js" ></script>

<script src="/js/iconfont.js?v=1.1.0" ></script>

<meta name="generator" content="Hexo 5.4.0"></head>
<div style="display: none">
  <input class="theme_disqus_on" value="false">
  <input class="theme_preload_comment" value="">
  <input class="theme_blog_path" value="">
  <input id="theme_shortcut" value="false" />
  <input id="theme_highlight_on" value="true" />
  <input id="theme_code_copy" value="true" />
</div>



<body>
<aside class="nav">
    <div class="nav-left">
        <a href="/"
   class="avatar_target">
    <img class="avatar"
         src="/img/avatar1.jpg"/>
</a>
<div class="author">
    <span>ShuYePL</span>
</div>

<div class="icon">
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            <a title="email"
               href="mailto:3548768596@qq.com"
               target="_blank">
                
                    <svg class="iconfont-svg" aria-hidden="true">
                        <use xlink:href="#icon-email"></use>
                    </svg>
                
            </a>
        
    
        
            <a title="qq"
               href="http://wpa.qq.com/msgrd?v=3&uin=3548768596&site=qq&menu=yes"
               target="_blank">
                
                    <svg class="iconfont-svg" aria-hidden="true">
                        <use xlink:href="#icon-qq"></use>
                    </svg>
                
            </a>
        
    
        
    
        
    
</div>




<ul>
    <li>
        <div class="all active" data-rel="All">All
            
                <small>(60)</small>
            
        </div>
    </li>
    
        
            
        
    
        
            
                <li>
                    <div data-rel="51单片机">
                        
                        51单片机
                        <small>(1)</small>
                        
                    </div>
                    
                </li>
            
        
    
        
            
                <li>
                    <div data-rel="博客">
                        <i class="fold iconfont icon-right"></i>
                        
                        博客
                        <small>(1)</small>
                        
                    </div>
                    
                        <ul class="sub hide">
                            
                                <li>
                                    <div data-rel="博客<--->Hexo">
                                        
                                        Hexo
                                        
                                            <small>(1
                                                )</small>
                                        
                                    </div>
                                    
                                </li>
                            
                        </ul>
                    
                </li>
            
        
    
        
            
                <li>
                    <div data-rel="博客建设">
                        
                        博客建设
                        <small>(3)</small>
                        
                    </div>
                    
                </li>
            
        
    
        
            
                <li>
                    <div data-rel="单片机">
                        <i class="fold iconfont icon-right"></i>
                        
                        单片机
                        <small>(1)</small>
                        
                    </div>
                    
                        <ul class="sub hide">
                            
                                <li>
                                    <div data-rel="单片机<--->51单片机">
                                        
                                        51单片机
                                        
                                            <small>(1
                                                )</small>
                                        
                                    </div>
                                    
                                </li>
                            
                        </ul>
                    
                </li>
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
                <li>
                    <div data-rel="数据结构与算法">
                        
                        数据结构与算法
                        <small>(1)</small>
                        
                    </div>
                    
                </li>
            
        
    
        
            
        
    
        
            
                <li>
                    <div data-rel="Git">
                        
                        Git
                        <small>(2)</small>
                        
                    </div>
                    
                </li>
            
        
    
        
            
        
    
        
            
                <li>
                    <div data-rel="IDE">
                        <i class="fold iconfont icon-right"></i>
                        
                        IDE
                        <small>(1)</small>
                        
                    </div>
                    
                        <ul class="sub hide">
                            
                                <li>
                                    <div data-rel="IDE<--->IDEA">
                                        
                                        IDEA
                                        
                                            <small>(1
                                                )</small>
                                        
                                    </div>
                                    
                                </li>
                            
                        </ul>
                    
                </li>
            
        
    
        
            
        
    
        
            
                <li>
                    <div data-rel="Java力扣刷题笔记">
                        
                        Java力扣刷题笔记
                        <small>(2)</small>
                        
                    </div>
                    
                </li>
            
        
    
        
            
                <li>
                    <div data-rel="Javase">
                        <i class="fold iconfont icon-right"></i>
                        
                        Javase
                        <small>(8)</small>
                        
                    </div>
                    
                        <ul class="sub hide">
                            
                                <li>
                                    <div data-rel="Javase<--->多线程">
                                        
                                        多线程
                                        
                                            <small>(1
                                                )</small>
                                        
                                    </div>
                                    
                                </li>
                            
                                <li>
                                    <div data-rel="Javase<--->集合">
                                        
                                        集合
                                        
                                            <small>(1
                                                )</small>
                                        
                                    </div>
                                    
                                </li>
                            
                                <li>
                                    <div data-rel="Javase<--->扩展运算符">
                                        
                                        扩展运算符
                                        
                                            <small>(1
                                                )</small>
                                        
                                    </div>
                                    
                                </li>
                            
                                <li>
                                    <div data-rel="Javase<--->命令行问题">
                                        
                                        命令行问题
                                        
                                            <small>(1
                                                )</small>
                                        
                                    </div>
                                    
                                </li>
                            
                                <li>
                                    <div data-rel="Javase<--->数组">
                                        
                                        数组
                                        
                                            <small>(1
                                                )</small>
                                        
                                    </div>
                                    
                                </li>
                            
                                <li>
                                    <div data-rel="Javase<--->ThreadLocal">
                                        
                                        ThreadLocal
                                        
                                            <small>(1
                                                )</small>
                                        
                                    </div>
                                    
                                </li>
                            
                        </ul>
                    
                </li>
            
        
    
        
            
                <li>
                    <div data-rel="JavaWeb">
                        
                        JavaWeb
                        <small>(22)</small>
                        
                    </div>
                    
                </li>
            
        
    
        
            
                <li>
                    <div data-rel="JDBC">
                        
                        JDBC
                        <small>(1)</small>
                        
                    </div>
                    
                </li>
            
        
    
        
            
                <li>
                    <div data-rel="Linux">
                        
                        Linux
                        <small>(2)</small>
                        
                    </div>
                    
                </li>
            
        
    
        
            
                <li>
                    <div data-rel="mybatis">
                        
                        mybatis
                        <small>(5)</small>
                        
                    </div>
                    
                </li>
            
        
    
        
            
                <li>
                    <div data-rel="SpringMVC">
                        
                        SpringMVC
                        <small>(1)</small>
                        
                    </div>
                    
                </li>
            
        
    
        
            
                <li>
                    <div data-rel="sql">
                        
                        sql
                        <small>(3)</small>
                        
                    </div>
                    
                </li>
            
        
    
        
            
        
    
        
            
                <li>
                    <div data-rel="UML">
                        
                        UML
                        <small>(1)</small>
                        
                    </div>
                    
                </li>
            
        
    
        
            
                <li>
                    <div data-rel="vscode使用">
                        
                        vscode使用
                        <small>(1)</small>
                        
                    </div>
                    
                </li>
            
        
    
        
            
                <li>
                    <div data-rel="Windows系统使用">
                        
                        Windows系统使用
                        <small>(1)</small>
                        
                    </div>
                    
                </li>
            
        
    
</ul>
<div class="left-bottom">
    <div class="menus">
        
            
            
            
    </div>
    <div>
        
        
    </div>
</div>
<input type="hidden" id="yelog_site_posts_number" value="60">

<div style="display: none">
    <span id="busuanzi_value_site_uv"></span>
    <span id="busuanzi_value_site_pv"></span>
</div>

    </div>
    <div class="nav-right">
        <div class="friends-area">
    <div class="friends-title">
        Links
        <i class="iconfont icon-left"></i>
    </div>
    <div class="friends-content">
        <ul>
            
            <li><a target="_blank" href="http://yelog.org/">叶落阁</a></li>
            
        </ul>
    </div>
</div>
        <div class="title-list">
    <div class="right-top">
        <div id="default-panel">
            <i class="iconfont icon-search" data-title="搜索"></i>
            <div class="right-title">All</div>
            <i class="iconfont icon-file-tree" data-title="切换到大纲视图"></i>
        </div>
        <div id="search-panel">
            <i class="iconfont icon-left" data-title="返回"></i>
            <input id="local-search-input" autocomplete="off"/>
            <label class="border-line" for="input"></label>
            <i class="iconfont icon-case-sensitive" data-title="大小写敏感"></i>
            <i class="iconfont icon-tag" data-title="标签"></i>
        </div>
        <div id="outline-panel" style="display: none">
            <div class="right-title">大纲</div>
            <i class="iconfont icon-list" data-title="切换到文章列表"></i>
        </div>
    </div>

    <div class="tags-list">
    <input id="tag-search" />
    <div class="tag-wrapper">
        
    </div>

</div>

    
    <nav id="title-list-nav">
        
        
        <a  class="All "
           href="/2023/04/12/%E7%BC%96%E7%A0%81/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="编码">编码</span>
            <span class="post-date" title="2023-04-12 09:40:51">2023/04/12</span>
        </a>
        
        
        <a  class="All JavaWeb "
           href="/2023/04/03/JWT/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="JWT">JWT</span>
            <span class="post-date" title="2023-04-03 22:33:20">2023/04/03</span>
        </a>
        
        
        <a  class="All mybatis "
           href="/2023/03/26/MyBatis%E4%B8%89%E5%A4%A7%E5%AF%B9%E8%B1%A1%E7%9A%84%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="MyBatis三大对象的生命周期">MyBatis三大对象的生命周期</span>
            <span class="post-date" title="2023-03-26 12:01:10">2023/03/26</span>
        </a>
        
        
        <a  class="All Javase ThreadLocal "
           href="/2023/03/26/ThreadLocal/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="ThreadLocal">ThreadLocal</span>
            <span class="post-date" title="2023-03-26 11:58:45">2023/03/26</span>
        </a>
        
        
        <a  class="All mybatis "
           href="/2023/03/25/MyBatis%E5%88%AB%E5%90%8D%E6%9C%BA%E5%88%B6/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="MyBatis别名机制">MyBatis别名机制</span>
            <span class="post-date" title="2023-03-25 15:07:07">2023/03/25</span>
        </a>
        
        
        <a  class="All mybatis "
           href="/2023/03/25/MyBatis%E4%B8%AD%E4%B8%A4%E7%A7%8D%E5%8D%A0%E4%BD%8D%E7%AC%A6%E7%9A%84%E5%8C%BA%E5%88%AB/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="MyBatis两种占位符的区别">MyBatis两种占位符的区别</span>
            <span class="post-date" title="2023-03-25 13:35:15">2023/03/25</span>
        </a>
        
        
        <a  class="All SpringMVC "
           href="/2023/03/24/springmvc%E7%9A%84%E4%B8%80%E4%B8%AA%E7%AE%80%E5%8D%95%E6%A8%A1%E6%9D%BF/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="springmvc的一个简单模板">springmvc的一个简单模板</span>
            <span class="post-date" title="2023-03-24 22:33:49">2023/03/24</span>
        </a>
        
        
        <a  class="All mybatis "
           href="/2023/03/24/MyBatis%E5%BC%95%E5%85%A5logback%E6%A1%86%E6%9E%B6/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="MyBatis引入logback框架">MyBatis引入logback框架</span>
            <span class="post-date" title="2023-03-24 14:20:51">2023/03/24</span>
        </a>
        
        
        <a  class="All Javase 集合 "
           href="/2023/03/21/Java%E9%9B%86%E5%90%88/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="Java集合">Java集合</span>
            <span class="post-date" title="2023-03-21 19:14:53">2023/03/21</span>
        </a>
        
        
        <a  class="All sql "
           href="/2023/03/17/MySQL%E5%9F%BA%E6%9C%AC%E8%AF%AD%E5%8F%A5/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="MySQL基本语句">MySQL基本语句</span>
            <span class="post-date" title="2023-03-17 09:55:20">2023/03/17</span>
        </a>
        
        
        <a  class="All Javase 多线程 "
           href="/2023/03/16/Java%E5%A4%9A%E7%BA%BF%E7%A8%8B/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="Java多线程">Java多线程</span>
            <span class="post-date" title="2023-03-16 19:14:28">2023/03/16</span>
        </a>
        
        
        <a  class="All sql "
           href="/2022/11/25/sql-%20%E6%8A%A5%E9%94%99%EF%BC%9APublic%20Key%20Retrieval%20is%20not%20allowed/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="sql- 报错：Public Key Retrieval is not allowed">sql- 报错：Public Key Retrieval is not allowed</span>
            <span class="post-date" title="2022-11-25 18:50:35">2022/11/25</span>
        </a>
        
        
        <a  class="All UML "
           href="/2022/11/25/UML-Rational%20Rose%E4%B8%8EUML%E7%AE%80%E5%8D%95%E7%AC%94%E8%AE%B0/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="UML-Rational Rose与UML简单笔记">UML-Rational Rose与UML简单笔记</span>
            <span class="post-date" title="2022-11-25 08:17:04">2022/11/25</span>
        </a>
        
        
        <a  class="All Javase 命令行问题 "
           href="/2022/11/18/Javase%E5%91%BD%E4%BB%A4%E8%A1%8C%E9%97%AE%E9%A2%98/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="Javase命令行问题">Javase命令行问题</span>
            <span class="post-date" title="2022-11-18 10:31:15">2022/11/18</span>
        </a>
        
        
        <a  class="All Javase "
           href="/2022/11/14/Javase-Lambda%E8%A1%A8%E8%BE%BE%E5%BC%8F/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="Javase-Lambda表达式">Javase-Lambda表达式</span>
            <span class="post-date" title="2022-11-14 15:19:33">2022/11/14</span>
        </a>
        
        
        <a  class="All Linux "
           href="/2022/11/06/Ubuntu-%E9%87%8D%E7%BD%AE%E5%AF%86%E7%A0%81/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="Ubuntu-重置密码">Ubuntu-重置密码</span>
            <span class="post-date" title="2022-11-06 16:00:22">2022/11/06</span>
        </a>
        
        
        <a  class="All 51单片机 "
           href="/2022/11/06/51%E5%8D%95%E7%89%87%E6%9C%BA-%E5%85%89%E7%AB%8B%E6%96%B9%E6%8E%A7%E5%88%B6%E6%96%B9%E6%A1%88%E7%90%86%E8%A7%A3/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="51单片机-光立方控制方案理解">51单片机-光立方控制方案理解</span>
            <span class="post-date" title="2022-11-06 14:45:13">2022/11/06</span>
        </a>
        
        
        <a  class="All 单片机 51单片机 "
           href="/2022/11/05/51%E5%8D%95%E7%89%87%E6%9C%BA/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="51单片机">51单片机</span>
            <span class="post-date" title="2022-11-05 12:31:18">2022/11/05</span>
        </a>
        
        
        <a  class="All "
           href="/2022/10/02/%E6%A6%82%E5%BF%B5%E4%B8%8E%E5%8D%95%E8%AF%8D/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="概念与单词">概念与单词</span>
            <span class="post-date" title="2022-10-02 20:57:00">2022/10/02</span>
        </a>
        
        
        <a  class="All Java力扣刷题笔记 "
           href="/2022/09/06/%E3%80%90Java%E5%8A%9B%E6%89%A3%E5%88%B7%E9%A2%98%E3%80%91%E9%A2%9820/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="【Java力扣刷题】题20">【Java力扣刷题】题20</span>
            <span class="post-date" title="2022-09-06 21:56:40">2022/09/06</span>
        </a>
        
        
        <a  class="All mybatis "
           href="/2022/09/04/Mybatis%E6%8A%A5%E9%94%99/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="Mybatis报错">Mybatis报错</span>
            <span class="post-date" title="2022-09-04 15:20:06">2022/09/04</span>
        </a>
        
        
        <a  class="All "
           href="/2022/07/18/esp32%E4%B8%8A%E4%BC%A0%E6%8A%A5%E9%94%99/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="esp32上传报错">esp32上传报错</span>
            <span class="post-date" title="2022-07-18 21:22:45">2022/07/18</span>
        </a>
        
        
        <a  class="All JavaWeb "
           href="/2022/07/18/%E8%BF%87%E6%BB%A4%E5%99%A8/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="过滤器">过滤器</span>
            <span class="post-date" title="2022-07-18 21:15:12">2022/07/18</span>
        </a>
        
        
        <a  class="All JavaWeb "
           href="/2022/07/18/%E7%9B%91%E5%90%AC%E5%99%A8/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="监听器">监听器</span>
            <span class="post-date" title="2022-07-18 21:14:07">2022/07/18</span>
        </a>
        
        
        <a  class="All JavaWeb "
           href="/2022/07/15/%E5%AE%89%E5%85%A8%E9%80%80%E5%87%BA%E7%B3%BB%E7%BB%9F%E4%BD%BF%E7%94%A8%E9%87%8D%E5%AE%9A%E5%90%91%E5%92%8C%E8%BD%AC%E5%8F%91%E7%9A%84%E5%8C%BA%E5%88%AB/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="安全退出系统使用重定向和转发的区别">安全退出系统使用重定向和转发的区别</span>
            <span class="post-date" title="2022-07-15 17:23:39">2022/07/15</span>
        </a>
        
        
        <a  class="All JavaWeb "
           href="/2022/07/15/session%E5%92%8Ccookie%E8%81%94%E5%90%88%E4%BD%BF%E7%94%A8%E6%97%B6%E7%9A%84%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="session和cookie联合使用时的注意事项">session和cookie联合使用时的注意事项</span>
            <span class="post-date" title="2022-07-15 13:38:13">2022/07/15</span>
        </a>
        
        
        <a  class="All JavaWeb "
           href="/2022/07/12/JSTL%E6%A0%87%E7%AD%BE%E5%BA%93/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="JSTL标签库.md">JSTL标签库.md</span>
            <span class="post-date" title="2022-07-12 22:28:02">2022/07/12</span>
        </a>
        
        
        <a  class="All JavaWeb "
           href="/2022/07/12/EL%E8%A1%A8%E8%BE%BE%E5%BC%8F/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="EL表达式.md">EL表达式.md</span>
            <span class="post-date" title="2022-07-12 21:17:09">2022/07/12</span>
        </a>
        
        
        <a  class="All JavaWeb "
           href="/2022/07/10/cookie/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="cookie.md">cookie.md</span>
            <span class="post-date" title="2022-07-10 10:36:12">2022/07/10</span>
        </a>
        
        
        <a  class="All JavaWeb "
           href="/2022/07/10/session/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="session.md">session.md</span>
            <span class="post-date" title="2022-07-10 09:12:24">2022/07/10</span>
        </a>
        
        
        <a  class="All JavaWeb "
           href="/2022/07/06/JSP%E8%81%94%E5%90%88Servlet%E5%BC%80%E5%8F%91%E7%AE%80%E5%8D%95WEB%E7%A8%8B%E5%BA%8F/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="JSP联合Servlet开发简单WEB程序">JSP联合Servlet开发简单WEB程序</span>
            <span class="post-date" title="2022-07-06 23:37:55">2022/07/06</span>
        </a>
        
        
        <a  class="All sql "
           href="/2022/07/06/%E4%BD%BF%E7%94%A8source%E5%AF%BC%E5%85%A5sql%E8%84%9A%E6%9C%AC%E8%B7%AF%E5%BE%84%E9%94%99%E8%AF%AF%EF%BC%88Windows%E5%B9%B3%E5%8F%B0%EF%BC%89/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="使用source导入sql脚本路径错误（Windows平台）">使用source导入sql脚本路径错误（Windows平台）</span>
            <span class="post-date" title="2022-07-06 21:30:11">2022/07/06</span>
        </a>
        
        
        <a  class="All Git "
           href="/2022/07/04/%E4%BD%BF%E7%94%A8Gitee%E4%BB%93%E5%BA%93%E5%A4%87%E4%BB%BD%E6%96%87%E4%BB%B6/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="使用Gitee仓库备份文件">使用Gitee仓库备份文件</span>
            <span class="post-date" title="2022-07-04 19:54:08">2022/07/04</span>
        </a>
        
        
        <a  class="All Git "
           href="/2022/07/04/Git%E5%9F%BA%E6%9C%AC%E4%BD%BF%E7%94%A8/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="Git基本使用">Git基本使用</span>
            <span class="post-date" title="2022-07-04 19:47:12">2022/07/04</span>
        </a>
        
        
        <a  class="All JavaWeb "
           href="/2022/06/30/JSP/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="JSP">JSP</span>
            <span class="post-date" title="2022-06-30 10:45:40">2022/06/30</span>
        </a>
        
        
        <a  class="All JavaWeb "
           href="/2022/06/28/%E6%B3%A8%E8%A7%A3%E5%BC%8F%E5%BC%80%E5%8F%91/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="注解式开发">注解式开发</span>
            <span class="post-date" title="2022-06-28 23:23:47">2022/06/28</span>
        </a>
        
        
        <a  class="All JavaWeb "
           href="/2022/06/28/%E8%BD%AC%E5%8F%91%E5%92%8C%E9%87%8D%E5%AE%9A%E5%90%91/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="转发和重定向">转发和重定向</span>
            <span class="post-date" title="2022-06-28 21:23:21">2022/06/28</span>
        </a>
        
        
        <a  class="All JavaWeb "
           href="/2022/06/28/mysql%20%E7%9A%84%20ResultSet%20%E4%BD%BF%E7%94%A8%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="mysql 的 ResultSet 使用注意事项">mysql 的 ResultSet 使用注意事项</span>
            <span class="post-date" title="2022-06-28 20:29:42">2022/06/28</span>
        </a>
        
        
        <a  class="All Java力扣刷题笔记 "
           href="/2022/06/24/%E3%80%90Java%20%E5%8A%9B%E6%89%A3%E5%88%B7%E9%A2%98%E3%80%91%E9%A2%982/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="【Java 力扣刷题】题2">【Java 力扣刷题】题2</span>
            <span class="post-date" title="2022-06-24 19:56:00">2022/06/24</span>
        </a>
        
        
        <a  class="All 博客建设 "
           href="/2022/06/24/Steam++%20%E6%8C%82%E4%BA%86%E8%BF%98%E6%98%AF%E4%B8%8A%E4%B8%8D%E5%8E%BB%20Github%20%E7%9A%84%E8%A7%A3%E5%86%B3%E6%96%B9%E6%B3%95/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="Steam++ 挂了还是上不去 Github 的解决方法">Steam++ 挂了还是上不去 Github 的解决方法</span>
            <span class="post-date" title="2022-06-24 09:28:00">2022/06/24</span>
        </a>
        
        
        <a  class="All 博客建设 "
           href="/2022/06/18/%E8%B4%AD%E4%B9%B0%E8%85%BE%E8%AE%AF%E4%BA%91%E7%9A%84%E6%9C%8D%E5%8A%A1%E5%99%A8/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="购买腾讯云的服务器">购买腾讯云的服务器</span>
            <span class="post-date" title="2022-06-18 15:08:00">2022/06/18</span>
        </a>
        
        
        <a  class="All JavaWeb "
           href="/2022/06/08/HttpServletRequest/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="HttpServletRequest">HttpServletRequest</span>
            <span class="post-date" title="2022-06-08 22:34:00">2022/06/08</span>
        </a>
        
        
        <a  class="All JavaWeb "
           href="/2022/06/07/HttpServlet/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="HttpServlet">HttpServlet</span>
            <span class="post-date" title="2022-06-07 15:25:00">2022/06/07</span>
        </a>
        
        
        <a  class="All 博客建设 "
           href="/2022/06/06/XSHELL%20%E5%92%8C%20Xftp%20%E7%9A%84%E4%B8%8B%E8%BD%BD%E5%AE%89%E8%A3%85/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="XSHELL 和 Xftp 的下载安装">XSHELL 和 Xftp 的下载安装</span>
            <span class="post-date" title="2022-06-06 11:40:00">2022/06/06</span>
        </a>
        
        
        <a  class="All JavaWeb "
           href="/2022/06/04/ServletConfig%20%E6%98%AF%E4%BB%80%E4%B9%88/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="ServletConfig 是什么">ServletConfig 是什么</span>
            <span class="post-date" title="2022-06-04 21:52:00">2022/06/04</span>
        </a>
        
        
        <a  class="All JavaWeb "
           href="/2022/06/04/%E9%80%82%E9%85%8D%E5%99%A8%E6%A8%A1%E5%BC%8F%E6%94%B9%E9%80%A0Servlet/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="适配器模式改造Servlet">适配器模式改造Servlet</span>
            <span class="post-date" title="2022-06-04 12:58:00">2022/06/04</span>
        </a>
        
        
        <a  class="All IDE IDEA "
           href="/2022/06/03/IDEA%20%E7%9B%B8%E5%85%B3%E5%86%85%E5%AE%B9/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="IDEA 相关内容">IDEA 相关内容</span>
            <span class="post-date" title="2022-06-03 16:58:00">2022/06/03</span>
        </a>
        
        
        <a  class="All JavaWeb "
           href="/2022/06/03/Servlet%20%E5%AF%B9%E8%B1%A1%E7%9A%84%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="Servlet 对象的生命周期">Servlet 对象的生命周期</span>
            <span class="post-date" title="2022-06-03 14:15:00">2022/06/03</span>
        </a>
        
        
        <a  class="All Linux "
           href="/2022/05/30/Linux%20%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="Linux 学习笔记">Linux 学习笔记</span>
            <span class="post-date" title="2022-05-30 20:19:00">2022/05/30</span>
        </a>
        
        
        <a  class="All Windows系统使用 "
           href="/2022/05/24/Win11%20%E6%96%87%E4%BB%B6%E6%98%BE%E7%A4%BA%E5%90%8E%E7%BC%80%E5%90%8D/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="Win11 文件显示后缀名">Win11 文件显示后缀名</span>
            <span class="post-date" title="2022-05-24 10:40:00">2022/05/24</span>
        </a>
        
        
        <a  class="All JavaWeb "
           href="/2022/05/07/%E4%BD%BF%E7%94%A8%20IDEA%20%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AA%20Tomcat%20%E9%A1%B9%E7%9B%AE/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="使用 IDEA 创建一个 Tomcat 项目">使用 IDEA 创建一个 Tomcat 项目</span>
            <span class="post-date" title="2022-05-07 22:37:00">2022/05/07</span>
        </a>
        
        
        <a  class="All JavaWeb "
           href="/2022/05/04/Servlet%20%E6%96%87%E4%BB%B6%E5%86%85%E5%AE%B9%E7%9A%84%E7%BB%93%E6%9E%84/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="Servlet 文件内容的结构">Servlet 文件内容的结构</span>
            <span class="post-date" title="2022-05-04 12:44:00">2022/05/04</span>
        </a>
        
        
        <a  class="All JavaWeb "
           href="/2022/05/03/Tomcat%20%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="Tomcat 环境配置">Tomcat 环境配置</span>
            <span class="post-date" title="2022-05-03 22:37:00">2022/05/03</span>
        </a>
        
        
        <a  class="All JDBC "
           href="/2022/05/03/JDBC%E7%9A%84%E4%BB%A3%E7%A0%81%E7%BB%93%E6%9E%84/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="JDBC的代码结构">JDBC的代码结构</span>
            <span class="post-date" title="2022-05-03 21:42:00">2022/05/03</span>
        </a>
        
        
        <a  class="All 数据结构与算法 "
           href="/2022/04/09/%E5%BF%AB%E9%80%9F%E6%8E%92%E5%BA%8F/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="快速排序">快速排序</span>
            <span class="post-date" title="2022-04-09 22:25:12">2022/04/09</span>
        </a>
        
        
        <a  class="All Javase 扩展运算符 "
           href="/2022/02/27/Java%E4%B8%AD%E7%9A%84%E6%89%A9%E5%B1%95%E8%BF%90%E7%AE%97%E7%AC%A6/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="Java中的扩展运算符">Java中的扩展运算符</span>
            <span class="post-date" title="2022-02-27 11:24:50">2022/02/27</span>
        </a>
        
        
        <a  class="All vscode使用 "
           href="/2021/12/10/vscode%E4%B8%AD%E5%87%BA%E7%8E%B0Open%20a%20folder%20or%20workspace...%E6%8A%A5%E9%94%99/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="vscode中出现Open a folder or workspace...报错">vscode中出现Open a folder or workspace...报错</span>
            <span class="post-date" title="2021-12-10 00:23:35">2021/12/10</span>
        </a>
        
        
        <a  class="All Javase "
           href="/2021/11/21/Java%20main%E6%96%B9%E6%B3%95%E4%B8%AD%E5%8F%82%E6%95%B0String%5B%5D%20args%E7%9A%84%E7%94%A8%E6%B3%95/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="Java main方法中参数String[] args的用法">Java main方法中参数String[] args的用法</span>
            <span class="post-date" title="2021-11-21 11:39:57">2021/11/21</span>
        </a>
        
        
        <a  class="All Javase 数组 "
           href="/2021/11/11/Java%E6%95%B0%E7%BB%84/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="Java数组">Java数组</span>
            <span class="post-date" title="2021-11-11 16:54:26">2021/11/11</span>
        </a>
        
        
        <a  class="All 博客 Hexo "
           href="/2021/10/27/Hexo%E5%8D%9A%E5%AE%A2%E6%90%AD%E5%BB%BA%E7%AC%94%E8%AE%B0/"
           data-tag=""
           data-author="" >
            <span class="post-title" title="Hexo博客搭建笔记">Hexo博客搭建笔记</span>
            <span class="post-date" title="2021-10-27 01:41:52">2021/10/27</span>
        </a>
        
        <div id="no-item-tips">

        </div>
    </nav>
    <div id="outline-list">
    </div>
</div>

    </div>
    <div class="hide-list">
        <div class="semicircle" data-title="切换全屏">
            <div class="brackets first"><</div>
            <div class="brackets">&gt;</div>
        </div>
    </div>
</aside>
<div id="post">
    <div class="pjax">
        <article id="post-MySQL基本语句" class="article article-type-post" itemscope itemprop="blogPost">
    
        <h1 class="article-title">MySQL基本语句</h1>
    
    <div class="article-meta">
        
        
        
        <span class="book">
            <i class="iconfont icon-category"></i>
            
            
            <a  data-rel="sql">sql</a>
            
        </span>
        
        
    </div>
    <div class="article-meta">
        
            Created At : <time class="date" title='Updated At: 2023-03-17 09:55:20'>2023-03-17 09:55</time>
        
    </div>
    <div class="article-meta">
        
        
        <span id="busuanzi_container_page_pv">
            Views 👀 :<span id="busuanzi_value_page_pv">
                <span class="count-comment">
                    <span class="spinner">
                      <div class="cube1"></div>
                      <div class="cube2"></div>
                    </span>
                </span>
            </span>
        </span>
        
        
    </div>
    
    <div class="toc-ref">
    
        <ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%9F%BA%E6%9C%AC%E6%A6%82%E5%BF%B5"><span class="toc-text">基本概念</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#MySQL%E7%9A%84%E5%90%AF%E5%8A%A8%E5%92%8C%E5%81%9C%E6%AD%A2%EF%BC%88Windows%E7%B3%BB%E7%BB%9F%EF%BC%89"><span class="toc-text">MySQL的启动和停止（Windows系统）</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#MySQL%E6%95%B0%E6%8D%AE%E5%BA%93%E7%9A%84%E7%99%BB%E5%BD%95"><span class="toc-text">MySQL数据库的登录</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#MySQL%E8%AF%AD%E5%8F%A5%E5%88%86%E7%B1%BB"><span class="toc-text">MySQL语句分类</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#DDL%EF%BC%88Data-Definition-Languages-%E6%95%B0%E6%8D%AE%E5%AE%9A%E4%B9%89%E8%AF%AD%E8%A8%80%EF%BC%89"><span class="toc-text">DDL（Data Definition Languages 数据定义语言）</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#DML%EF%BC%88Data-Manipulation-Language-%E6%95%B0%E6%8D%AE%E6%93%8D%E4%BD%9C%E8%AF%AD%E5%8F%A5%EF%BC%89"><span class="toc-text">DML（Data Manipulation Language 数据操作语句）</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#DCL%EF%BC%88Data-Control-Languege-%E6%95%B0%E6%8D%AE%E6%8E%A7%E5%88%B6%E8%AF%AD%E5%8F%A5%EF%BC%89"><span class="toc-text">DCL（Data Control Languege 数据控制语句）</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#DDL%E5%9F%BA%E6%9C%AC%E8%AF%AD%E5%8F%A5"><span class="toc-text">DDL基本语句</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%95%B0%E6%8D%AE%E5%BA%93%E6%93%8D%E4%BD%9C"><span class="toc-text">数据库操作</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%88%9B%E5%BB%BA%E6%95%B0%E6%8D%AE%E5%BA%93"><span class="toc-text">创建数据库</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%88%A0%E9%99%A4%E6%95%B0%E6%8D%AE%E5%BA%93"><span class="toc-text">删除数据库</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%88%87%E6%8D%A2%E6%95%B0%E6%8D%AE%E5%BA%93"><span class="toc-text">切换数据库</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%AE%BE%E7%BD%AE%E7%BC%96%E7%A0%81%E6%A0%BC%E5%BC%8F"><span class="toc-text">设置编码格式</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%A1%A8%E6%93%8D%E4%BD%9C"><span class="toc-text">表操作</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%88%9B%E5%BB%BA%E8%A1%A8"><span class="toc-text">创建表</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%9F%A5%E7%9C%8B%E8%A1%A8%E7%9A%84%E5%AE%9A%E4%B9%89"><span class="toc-text">查看表的定义</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%9F%A5%E7%9C%8B%E5%BB%BA%E8%A1%A8%E8%AF%AD%E5%8F%A5"><span class="toc-text">查看建表语句</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%88%A0%E9%99%A4%E8%A1%A8"><span class="toc-text">删除表</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BF%AE%E6%94%B9%E8%A1%A8"><span class="toc-text">修改表</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E4%BF%AE%E6%94%B9%E5%AD%97%E6%AE%B5%E7%B1%BB%E5%9E%8B"><span class="toc-text">修改字段类型</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%A2%9E%E5%8A%A0%E8%A1%A8%E5%AD%97%E6%AE%B5"><span class="toc-text">增加表字段</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%88%A0%E9%99%A4%E5%AD%97%E6%AE%B5"><span class="toc-text">删除字段</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%AD%97%E6%AE%B5%E6%94%B9%E5%90%8D"><span class="toc-text">字段改名</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%94%B9%E5%8F%98%E5%AD%97%E6%AE%B5%E9%A1%BA%E5%BA%8F"><span class="toc-text">改变字段顺序</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E4%BF%AE%E6%94%B9%E8%A1%A8%E5%90%8D"><span class="toc-text">修改表名</span></a></li></ol></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#DML%E5%9F%BA%E6%9C%AC%E8%AF%AD%E5%8F%A5"><span class="toc-text">DML基本语句</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%8F%92%E5%85%A5%E8%A1%A8%E6%95%B0%E6%8D%AE"><span class="toc-text">插入表数据</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#INSERT-INTO-%E8%AF%AD%E5%8F%A5"><span class="toc-text">INSERT INTO 语句</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%BF%AE%E6%94%B9%E8%A1%A8%E6%95%B0%E6%8D%AE"><span class="toc-text">修改表数据</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#update%E8%AF%AD%E5%8F%A5"><span class="toc-text">update语句</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%88%A0%E9%99%A4%E8%AE%B0%E5%BD%95"><span class="toc-text">删除记录</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#delete%E8%AF%AD%E5%8F%A5"><span class="toc-text">delete语句</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%9F%A5%E8%AF%A2%E8%A1%A8%E8%AE%B0%E5%BD%95"><span class="toc-text">查询表记录</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#select%E8%AF%AD%E5%8F%A5"><span class="toc-text">select语句</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#distinct%E5%8E%BB%E9%87%8D%E6%9F%A5%E8%AF%A2"><span class="toc-text">distinct去重查询</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#order-by%E6%9F%A5%E8%AF%A2%E7%BB%93%E6%9E%9C%E6%8E%92%E5%BA%8F"><span class="toc-text">order by查询结果排序</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#where%E6%9D%A1%E4%BB%B6%E6%9F%A5%E8%AF%A2"><span class="toc-text">where条件查询</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E8%BF%90%E7%AE%97%E7%AC%A6%E4%BD%BF%E7%94%A8"><span class="toc-text">运算符使用</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#like%E5%AD%97%E5%8F%A5"><span class="toc-text">like字句</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#%E9%80%9A%E9%85%8D%E7%AC%A6"><span class="toc-text">通配符</span></a></li></ol></li><li class="toc-item toc-level-4"><a class="toc-link" href="#in%E5%AD%97%E5%8F%A5"><span class="toc-text">in字句</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#between%E5%AD%97%E5%8F%A5"><span class="toc-text">between字句</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#limit%E9%99%90%E5%88%B6%E6%98%BE%E7%A4%BA%E7%9A%84%E6%95%B0%E6%8D%AE%E6%9D%A1%E6%95%B0"><span class="toc-text">limit限制显示的数据条数</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%81%9A%E5%90%88%E6%93%8D%E4%BD%9C"><span class="toc-text">聚合操作</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#union-all%E5%92%8Cunion%E8%AF%AD%E5%8F%A5"><span class="toc-text">union all和union语句</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%BF%9E%E6%8E%A5%E6%9F%A5%E8%AF%A2"><span class="toc-text">连接查询</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#%E5%86%85%E8%BF%9E%E6%8E%A5"><span class="toc-text">内连接</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#%E5%A4%96%E8%BF%9E%E6%8E%A5"><span class="toc-text">外连接</span></a></li></ol></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%88%AB%E5%90%8D"><span class="toc-text">别名</span></a></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#DCL%E8%AF%AD%E5%8F%A5"><span class="toc-text">DCL语句</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%8E%88%E4%BA%88%E6%9D%83%E9%99%90"><span class="toc-text">授予权限</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%9B%9E%E6%94%B6%E6%9D%83%E9%99%90"><span class="toc-text">回收权限</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%88%A0%E9%99%A4%E7%94%A8%E6%88%B7"><span class="toc-text">删除用户</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%B8%AE%E5%8A%A9%E5%91%BD%E4%BB%A4"><span class="toc-text">帮助命令</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E7%BB%86%E7%A2%8E%E7%9A%84%E7%9F%A5%E8%AF%86%E7%82%B9"><span class="toc-text">细碎的知识点</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%96%87%E6%9C%AC%E5%80%BC"><span class="toc-text">文本值</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#having%E5%92%8Cwhere%E7%9A%84%E5%8C%BA%E5%88%AB"><span class="toc-text">having和where的区别</span></a></li></ol></li></ol>
    
<style>
    .left-col .switch-btn,
    .left-col .switch-area {
        display: none;
    }
    .toc-level-3 i,
    .toc-level-3 ol {
        display: none !important;
    }
</style>
</div>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h1 id="基本概念"><a href="#基本概念" class="headerlink" title="基本概念"></a>基本概念</h1><p><strong>SQL</strong> (Structured Query Language:结构化查询语言)，用于管理关系数据库管理系统（RDBMS），它是一种与数据库交互的语言，很多关系型数据库系统都支持SQL语言。（下面的内容都是是MySQL为例的）</p>
<h1 id="MySQL的启动和停止（Windows系统）"><a href="#MySQL的启动和停止（Windows系统）" class="headerlink" title="MySQL的启动和停止（Windows系统）"></a>MySQL的启动和停止（Windows系统）</h1><p>启动</p>
<pre><code>net start MySQL80
</code></pre>
<p>停止</p>
<pre><code>net stop MySQL80
</code></pre>
<p>stop 后面跟着的名字要去查一下自己电脑上的MySQL服务的名称是什么，要和这个服务的名字对应上。然后，在命令行输入这两条命令的时候是需要管理员权限的，如果没有开启管理员权限的话会报下面的错误信息</p>
<pre><code>C:\Users\jh&gt;net stop MySQL80
发生系统错误 5。

拒绝访问。
</code></pre>
<p>打开管理员权限的命令行操作：<a target="_blank" rel="noopener" href="https://blog.csdn.net/m0_58547974/article/details/119978383">(10条消息) 使用管理员权限打开cmd（命令提示符）的方法 （Windows10）_lgxo的博客-CSDN博客</a></p>
<p>正常启动与停止服务</p>
<pre><code>C:\WINDOWS\system32&gt;net start MySQL80
MySQL80 服务正在启动 .
MySQL80 服务已经启动成功。

C:\WINDOWS\system32&gt;net stop MySQL80
MySQL80 服务正在停止.
MySQL80 服务已成功停止。
</code></pre>
<h1 id="MySQL数据库的登录"><a href="#MySQL数据库的登录" class="headerlink" title="MySQL数据库的登录"></a>MySQL数据库的登录</h1><pre><code>mysql -uroot -p
</code></pre>
<p>输入上面的命令后回车，输入密码，再回车。</p>
<h1 id="MySQL语句分类"><a href="#MySQL语句分类" class="headerlink" title="MySQL语句分类"></a>MySQL语句分类</h1><h2 id="DDL（Data-Definition-Languages-数据定义语言）"><a href="#DDL（Data-Definition-Languages-数据定义语言）" class="headerlink" title="DDL（Data Definition Languages 数据定义语言）"></a>DDL（Data Definition Languages 数据定义语言）</h2><p>主要用在数据库对象的创建、删除、修改等操作，不涉及表内的数据操作</p>
<h2 id="DML（Data-Manipulation-Language-数据操作语句）"><a href="#DML（Data-Manipulation-Language-数据操作语句）" class="headerlink" title="DML（Data Manipulation Language 数据操作语句）"></a>DML（Data Manipulation Language 数据操作语句）</h2><p>主要负责对表内数据的操作，基本的CRUD都在这里。</p>
<h2 id="DCL（Data-Control-Languege-数据控制语句）"><a href="#DCL（Data-Control-Languege-数据控制语句）" class="headerlink" title="DCL（Data Control Languege 数据控制语句）"></a>DCL（Data Control Languege 数据控制语句）</h2><p>对于访问权限的控制。</p>
<h1 id="DDL基本语句"><a href="#DDL基本语句" class="headerlink" title="DDL基本语句"></a>DDL基本语句</h1><h2 id="数据库操作"><a href="#数据库操作" class="headerlink" title="数据库操作"></a>数据库操作</h2><h3 id="创建数据库"><a href="#创建数据库" class="headerlink" title="创建数据库"></a>创建数据库</h3><pre><code class="mysql">create database dbname
</code></pre>
<h3 id="删除数据库"><a href="#删除数据库" class="headerlink" title="删除数据库"></a>删除数据库</h3><pre><code class="mysql">drop database dbname
</code></pre>
<h3 id="切换数据库"><a href="#切换数据库" class="headerlink" title="切换数据库"></a>切换数据库</h3><pre><code class="mysql">use dbname
</code></pre>
<h2 id="设置编码格式"><a href="#设置编码格式" class="headerlink" title="设置编码格式"></a>设置编码格式</h2><pre><code class="mysql">set names utf8;
</code></pre>
<h2 id="表操作"><a href="#表操作" class="headerlink" title="表操作"></a>表操作</h2><h3 id="创建表"><a href="#创建表" class="headerlink" title="创建表"></a>创建表</h3><pre><code class="mysql">create table emp(ename varchar(10), hiredate date, sal decimal(10, 2), deptno int(2));
</code></pre>
<h3 id="查看表的定义"><a href="#查看表的定义" class="headerlink" title="查看表的定义"></a>查看表的定义</h3><pre><code class="mysql">desc 表名;
</code></pre>
<h3 id="查看建表语句"><a href="#查看建表语句" class="headerlink" title="查看建表语句"></a>查看建表语句</h3><pre><code class="mysql">show create table 表名 \G;
</code></pre>
<h3 id="删除表"><a href="#删除表" class="headerlink" title="删除表"></a>删除表</h3><pre><code class="mysql">drop table 表名;
</code></pre>
<h3 id="修改表"><a href="#修改表" class="headerlink" title="修改表"></a>修改表</h3><h4 id="修改字段类型"><a href="#修改字段类型" class="headerlink" title="修改字段类型"></a>修改字段类型</h4><pre><code class="mysql">alter table 表名 modify 字段名 字段类型(字段长度);
</code></pre>
<h4 id="增加表字段"><a href="#增加表字段" class="headerlink" title="增加表字段"></a>增加表字段</h4><pre><code class="mysql">alter table 表名 add column 字段名 字段类型(字段长度);
</code></pre>
<h4 id="删除字段"><a href="#删除字段" class="headerlink" title="删除字段"></a>删除字段</h4><pre><code class="mysql">alter table 表名 drop column 字段名;
</code></pre>
<h4 id="字段改名"><a href="#字段改名" class="headerlink" title="字段改名"></a>字段改名</h4><pre><code class="mysql">alter table 表名 change 旧字段名 新字段名 字段类型(字段长度);
</code></pre>
<h4 id="改变字段顺序"><a href="#改变字段顺序" class="headerlink" title="改变字段顺序"></a>改变字段顺序</h4><p>对于上面的操作，add默认将字段增加在现有字段的后面，chage和modify默认不会改变字段的位置，如果在上面的这些alter语句后面加上[first|after column_name]的话就可以改变字段的位置，first或者after后面的<strong>字段名</strong>如果没有指定的话，默认是放在整张表字段的最前方，或者整张表字段的最后面，例子：</p>
<pre><code class="mysql">alter table 表名 add 新添加的字段 字段类型 after 添加在该字段的后面;
</code></pre>
<h4 id="修改表名"><a href="#修改表名" class="headerlink" title="修改表名"></a>修改表名</h4><pre><code class="mysql">alter table 表名 rename 新表名;
</code></pre>
<h1 id="DML基本语句"><a href="#DML基本语句" class="headerlink" title="DML基本语句"></a>DML基本语句</h1><h2 id="插入表数据"><a href="#插入表数据" class="headerlink" title="插入表数据"></a>插入表数据</h2><h3 id="INSERT-INTO-语句"><a href="#INSERT-INTO-语句" class="headerlink" title="INSERT INTO 语句"></a>INSERT INTO 语句</h3><pre><code class="mysql">INSERT INTO table_name
VALUES (value1,value2,value3,...);
或者
INSERT INTO table_name (column1,column2,column3,...)
VALUES (value1,value2,value3,...);
</code></pre>
<h2 id="修改表数据"><a href="#修改表数据" class="headerlink" title="修改表数据"></a>修改表数据</h2><h3 id="update语句"><a href="#update语句" class="headerlink" title="update语句"></a>update语句</h3><pre><code class="mysql">UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;
</code></pre>
<h2 id="删除记录"><a href="#删除记录" class="headerlink" title="删除记录"></a>删除记录</h2><h3 id="delete语句"><a href="#delete语句" class="headerlink" title="delete语句"></a>delete语句</h3><pre><code class="mysql">DELETE FROM table_name
WHERE condition;

删除所有数据，但保留表
DELETE FROM table_name;
</code></pre>
<h2 id="查询表记录"><a href="#查询表记录" class="headerlink" title="查询表记录"></a>查询表记录</h2><h3 id="select语句"><a href="#select语句" class="headerlink" title="select语句"></a>select语句</h3><pre><code class="mysql">SELECT column1, column2, ...
FROM table_name;
或者
SELECT * FROM table_name;
</code></pre>
<h3 id="distinct去重查询"><a href="#distinct去重查询" class="headerlink" title="distinct去重查询"></a>distinct去重查询</h3><pre><code class="mysql">SELECT DISTINCT column1, column2, ...
FROM table_name;
</code></pre>
<p>distinct后面跟着的字段都会被作为筛选的条件</p>
<h3 id="order-by查询结果排序"><a href="#order-by查询结果排序" class="headerlink" title="order by查询结果排序"></a>order by查询结果排序</h3><pre><code class="mysql">SELECT column1, column2, ...
FROM table_name
ORDER BY column1, column2, ... ASC|DESC;
</code></pre>
<p>order by默认情况下是升序排序的，ASC指定为升序，DESC指定为降序，每个字段后面都可以指定降序排序还是升序排序，生效字段按照出现的顺序从左到右生效。</p>
<h3 id="where条件查询"><a href="#where条件查询" class="headerlink" title="where条件查询"></a>where条件查询</h3><pre><code class="mysql">SELECT column1, column2, ...
FROM table_name
WHERE condition;
</code></pre>
<h4 id="运算符使用"><a href="#运算符使用" class="headerlink" title="运算符使用"></a>运算符使用</h4><pre><code class="mysql">select * from websites where country=&#39;CN&#39; and alexa &gt; 50

select * from websites where country=&#39;USA&#39; or country=&#39;CN&#39;;
</code></pre>
<h4 id="like字句"><a href="#like字句" class="headerlink" title="like字句"></a>like字句</h4><pre><code class="mysql">SELECT column1, column2, ...
FROM table_name
WHERE column LIKE pattern;

SELECT * FROM Websites
WHERE name NOT LIKE &#39;%oo%&#39;;
</code></pre>
<h5 id="通配符"><a href="#通配符" class="headerlink" title="通配符"></a>通配符</h5><table>
<thead>
<tr>
<th align="center">通配符</th>
<th align="center">代表含义</th>
</tr>
</thead>
<tbody><tr>
<td align="center">%</td>
<td align="center">0个或多个字符</td>
</tr>
<tr>
<td align="center">_</td>
<td align="center">一个字符</td>
</tr>
<tr>
<td align="center">[字符列表]</td>
<td align="center">字符列表中的一个字符</td>
</tr>
<tr>
<td align="center">[^字符列表]</td>
<td align="center">不在字符列表中的一个字符</td>
</tr>
<tr>
<td align="center">[!字符列表]</td>
<td align="center">不在字符列表中的一个字符</td>
</tr>
</tbody></table>
<p>前两个通配符配合like和not like使用，后三个字符列表相关的通配符是正则表达式的。</p>
<h4 id="in字句"><a href="#in字句" class="headerlink" title="in字句"></a>in字句</h4><pre><code class="mysql">SELECT column1, column2, ...
FROM table_name
WHERE column IN (value1, value2, ...);
</code></pre>
<p>与in对应的还有一个not in的。</p>
<h4 id="between字句"><a href="#between字句" class="headerlink" title="between字句"></a>between字句</h4><pre><code class="mysql">SELECT column1, column2, ...
FROM table_name
WHERE column BETWEEN value1 AND value2;

SELECT * FROM Websites
WHERE alexa NOT BETWEEN 1 AND 20;
</code></pre>
<p>between可以操作数值、字符、日期。</p>
<h3 id="limit限制显示的数据条数"><a href="#limit限制显示的数据条数" class="headerlink" title="limit限制显示的数据条数"></a>limit限制显示的数据条数</h3><pre><code class="mysql">SELECT column_name(s)
FROM table_name
LIMIT number;
</code></pre>
<p>还可以指定从哪一条记录开始显示，显示number条数据，起始下标从0开始</p>
<pre><code class="mysql">select * from emp limit 起始下标,显示数据条数;
</code></pre>
<h3 id="聚合操作"><a href="#聚合操作" class="headerlink" title="聚合操作"></a>聚合操作</h3><p>这里需要用到一些MySQL的函数了，这个算是属于综合查询了</p>
<pre><code class="mysql">SELECT [fieldl,field2,....fieldn] fun_name 
FROM tablename
[WHERE where_contition] 
[GROUP BY field1,field2,....fieldn [WITH ROLLUP]]
[HAVING where_contition]
</code></pre>
<p><code>with rollup</code>的作用是统计总数量。</p>
<h3 id="union-all和union语句"><a href="#union-all和union语句" class="headerlink" title="union all和union语句"></a>union all和union语句</h3><p>将查询的结果进行合并，其中union all不会去重，而union会进行去重，使用方式就是左右两边两个select语句，中间一个union或者union all。</p>
<pre><code class="mysql">(select...) union (select...)

(select...) union all (select...)
</code></pre>
<h3 id="连接查询"><a href="#连接查询" class="headerlink" title="连接查询"></a>连接查询</h3><p>连接分为内连接和外连接，区别是内连接匹配两张表都有的，而外连接能匹配表中不匹配的</p>
<h5 id="内连接"><a href="#内连接" class="headerlink" title="内连接"></a>内连接</h5><pre><code class="mysql">select ename,deptname from emp, dept where emp.deptno = dept.deptno;
</code></pre>
<h5 id="外连接"><a href="#外连接" class="headerlink" title="外连接"></a>外连接</h5><pre><code class="mysql">SELECT column1, column2, ...
FROM table1
JOIN table2 ON condition;
</code></pre>
<h3 id="别名"><a href="#别名" class="headerlink" title="别名"></a>别名</h3><p>可以为表名或者列名指定别名。</p>
<pre><code class="mysql">SELECT column_name AS alias_name
FROM table_name;
</code></pre>
<h1 id="DCL语句"><a href="#DCL语句" class="headerlink" title="DCL语句"></a>DCL语句</h1><p>这一部分的内容主要是DBA在操作的，用于权限控制使用</p>
<h2 id="授予权限"><a href="#授予权限" class="headerlink" title="授予权限"></a>授予权限</h2><p><del>用grant一键创建用户并且授权的方式在8.0版本的MySQL不能使用了</del></p>
<p>8.0版本授予权限必须先创建用户、再授予权限、刷新权限。</p>
<pre><code class="mysql">create user &#39;z1&#39;@&#39;localhost&#39; identified by &#39;123&#39;;
grant insert,select on test1.* to &#39;z1&#39;@&#39;localhost&#39;;
flush privileges;
</code></pre>
<h2 id="回收权限"><a href="#回收权限" class="headerlink" title="回收权限"></a>回收权限</h2><pre><code class="mysql">revoke insert on test1.* from &#39;z1&#39;@&#39;localhost&#39;;
</code></pre>
<h2 id="删除用户"><a href="#删除用户" class="headerlink" title="删除用户"></a>删除用户</h2><pre><code class="mysql">drop user &#39;z1&#39;@&#39;localhost&#39;;
</code></pre>
<h1 id="帮助命令"><a href="#帮助命令" class="headerlink" title="帮助命令"></a>帮助命令</h1><p>查看可供查询的分类</p>
<pre><code class="mysql">? contents
</code></pre>
<p>查看分类细节</p>
<pre><code class="mysql">? 类别名称（上个指令中列出来的）
</code></pre>
<p>依次类推的，对于上一个指令列出来的内容，还可以继续?对详细信息进行查询</p>
<h1 id="细碎的知识点"><a href="#细碎的知识点" class="headerlink" title="细碎的知识点"></a>细碎的知识点</h1><h2 id="文本值"><a href="#文本值" class="headerlink" title="文本值"></a>文本值</h2><p>文本值（这里我觉得就是字符类型）使用 ‘’ 或者 “” 包围起来表示，如果是数字，可以直接使用，不需要使用单引号或者双引号包围起来，SQL对于大小写不敏感不只是对于关键字，而且对于文本值来说也是大小写不敏感的。对于查询语句是不敏感的，但是你插入进去数据库中的字符串是区分大小写的。</p>
<h2 id="having和where的区别"><a href="#having和where的区别" class="headerlink" title="having和where的区别"></a>having和where的区别</h2><p>having是对聚合之后的结果再进行过滤操作，而where是在聚合前先对解过进行过滤然后再进行聚合操作。在实际操作数据库的时候尽量先使用where过滤，然后再聚合，减少操作的数据量，聚合的效率更高一些。</p>
<hr>
<p>参考资料：</p>
<ul>
<li>菜鸟教程–&gt;SQL教程：<a target="_blank" rel="noopener" href="https://www.runoob.com/sql/sql-tutorial.html">SQL 教程 | 菜鸟教程 (runoob.com)</a></li>
<li>深入浅出MySQL  数据库开发、优化、与管理维护（第二版 唐汉明）</li>
<li><a target="_blank" rel="noopener" href="http://c.biancheng.net/view/2613.html">MySQL删除用户（DROP USER） (biancheng.net)</a></li>
</ul>

      
       <hr><span style="font-style: italic;color: gray;"> 转载请注明来源，欢迎对文章中的引用来源进行考证，欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论，也可以邮件至 3548768596@qq.com </span>
    </div>
</article>







    




    </div>
    <div class="copyright">
        <p class="footer-entry">
    ©2017 ShuYePL
</p>
<p class="footer-entry">Built with <a href="https://hexo.io/" target="_blank">Hexo</a> and <a href="https://github.com/yelog/hexo-theme-3-hexo" target="_blank">3-hexo</a> theme</p>

    </div>
    <div class="full-toc">
        <button class="full" data-title="切换全屏"><span class="min "></span></button>
<a class="" id="rocket" ></a>

    </div>
</div>

<script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginModelPath":"assets/","model":{"jsonPath":"live2d-widget-model-hijiki"},"display":{"position":"right","width":150,"height":300},"mobile":{"show":false},"rect":"opacity:0.7","log":false,"pluginJsPath":"lib/","pluginRootPath":"live2dw/","tagMode":false});</script></body>
<script src="/js/jquery.pjax.js?v=1.1.0" ></script>

<script src="/js/script.js?v=1.1.0" ></script>
<script>
    var img_resize = 'default';
    function initArticle() {
        /*渲染对应的表格样式*/
        
            $("#post .pjax table").addClass("green_title");
        

        /*渲染打赏样式*/
        

        /*高亮代码块行号*/
        

        /*访问数量*/
        
        $.getScript("//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js");
        

        /*代码高亮，行号对齐*/
        $('.pre-numbering').css('line-height',$('.has-numbering').css('line-height'));

        
        
    }

    /*打赏页面隐藏与展示*/
    

</script>

<!--加入行号的高亮代码块样式-->

<!--自定义样式设置-->
<style>
    
    
    .nav {
        width: 542px;
    }
    .nav.fullscreen {
        margin-left: -542px;
    }
    .nav-left {
        width: 120px;
    }
    
    
    @media screen and (max-width: 1468px) {
        .nav {
            width: 492px;
        }
        .nav.fullscreen {
            margin-left: -492px;
        }
        .nav-left {
            width: 100px;
        }
    }
    
    
    @media screen and (max-width: 1024px) {
        .nav {
            width: 492px;
            margin-left: -492px
        }
        .nav.fullscreen {
            margin-left: 0;
        }
    }
    
    @media screen and (max-width: 426px) {
        .nav {
            width: 100%;
        }
        .nav-left {
            width: 100%;
        }
    }
    
    
    .nav-right .title-list nav a .post-title, .nav-right .title-list #local-search-result a .post-title {
        color: #383636;
    }
    
    
    .nav-right .title-list nav a .post-date, .nav-right .title-list #local-search-result a .post-date {
        color: #5e5e5f;
    }
    
    
    .nav-right nav a.hover, #local-search-result a.hover{
        background-color: #2e2f2f;
    }
    
    
    .nav-right nav a.hover > span{
        color: #ffffff !important;
    }
    

    /*列表样式*/
    

    /* 背景图样式 */
    
    #post {
        background: url(https://i.loli.net/2019/07/22/5d3521411f3f169375.png);
    }
    
    
    #post .index {
        background: url(https://i.loli.net/2019/07/22/5d3521411f3f169375.png);
    }
    


    /*引用块样式*/
    

    /*文章列表背景图*/
    
    .nav-right:before {
        content: ' ';
        display: block;
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        opacity: 0.4;
        background: url("https://i.loli.net/2019/07/22/5d3521411f3f169375.png");
        background-repeat: no-repeat;
        background-position: 50% 0;
        -ms-background-size: cover;
        -o-background-size: cover;
        -moz-background-size: cover;
        -webkit-background-size: cover;
        background-size: cover;
    }
    

    
</style>







</html>
